package com.ymatou.iapi.productmanager.testcase;

import com.ymatou.iapi.productmanager.parameter.AutoRefreshProductsMessageHandlerBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productmanager.service.AutoRefreshProductsMessageHandlerCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.business.service.ProductManagerCallServiceV3;
import com.ymttest.database.sqlwapper.IntergratedProductMapper;
import com.ymttest.database.sqlwapper.YmtProductsIWapper;
import com.ymttest.utils.YMTDateUtil;

import org.json.JSONObject;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

//port com.ymttest.database.annotation.product.IntergratedProductMapper;
/**
*定时自动延期商品
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_AutoRefreshProductsMessageHandler{
	private static AutoRefreshProductsMessageHandlerBean autorefreshproductsmessagehandlerBean;
	private static AutoRefreshProductsMessageHandlerCall autorefreshproductsmessagehandlerCall;
	//private static IntergratedProductMapper intergratedProductMapper = SqlMapperFactory.getIntergratedProductMapper();
	private static IntergratedProductMapper intergratedProductMapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("定时自动延期商品");
	}

	@Before
	public void caseUp() {
		autorefreshproductsmessagehandlerBean=new AutoRefreshProductsMessageHandlerBean();
		autorefreshproductsmessagehandlerCall=new AutoRefreshProductsMessageHandlerCall();
		intergratedProductMapper = new IntergratedProductMapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(autorefreshproductsmessagehandlerCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AutoRefreshProductsMessageHandler_001() {
		Logger.start(true,"3天内到期bAutoRefresh为true的商品定时自动延期商品成功");
		try {
			Integer sellerId=3383;
			String sellerName="wesper";
//			//删除同步记录
			intergratedProductMapper.deleteSellerLoginInfoByUserId(sellerId);
		//	Map<String, Object> updateMap = new HashMap<String, Object>();

//			updateMap.put("sellerName", sellerName);
//			updateMap.put("sellerId", sellerId);
//			//拼邮
//			updateMap.put("product->catalogStatus", 7);
//			//使用原时间 影响validStart validEnd
//			updateMap.put("product->onSaleType", -1);
//			//设置自动上架
//			updateMap.put("product->autoRefresh", true);
//			updateMap.put("product->productName",
//					"自动化测试_定时上架商品 "
//							+ YMTDateUtil.getBeforeOrNextDay(0));

			//设为为过去10天前发布的商品
			String vstart=YMTDateUtil.getBeforeOrNextDay(-10, YMTDateUtil.YMDTHMS_STRING);
		//	updateMap.put("product->validStart", vstart);
			String vend=YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
		//	updateMap.put("product->validEnd", vend);
			//JSONObject addNewProducthistoryObject = ProductManagerCallServiceV2.addNewProduct(updateMap);
			
			// update by wuwen addproductmock
            AddSellerProductRequest addProdReq = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
            addProdReq.setSellerId(sellerId);
            addProdReq.setSellerName(sellerName);
            addProdReq.getProduct().setCatalogStatus(5);
            addProdReq.getProduct().setOnSaleType(-1);
            addProdReq.getProduct().setAutoRefresh(true);
            addProdReq.getProduct().setProductName("自动化测试_定时上架商品"+ YMTDateUtil.getBeforeOrNextDay(0));
            addProdReq.getProduct().setValidStart(vstart);
            addProdReq.getProduct().setValidEnd(vend);
            String productID = ProductManagerCallServiceV3.AddSellerProduct(addProdReq);
			
//			Logger.verifyEquals(addNewProducthistoryObject.getInt("Code"), 200, "响应报文-返回码");
//			String productID =  addNewProducthistoryObject.getJSONObject("Data").getString("ProductId");
			YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
			List<Map> productIDsqllist1 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validStart"));
			String svalidEndbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validEnd"));	
			autorefreshproductsmessagehandlerBean.setUserId(sellerId);
			autorefreshproductsmessagehandlerCall.setData(autorefreshproductsmessagehandlerBean);
			autorefreshproductsmessagehandlerCall.callService();			
			Logger.verifyEquals("ok", autorefreshproductsmessagehandlerCall.getReturnData(), "验证返回");
			//发送总线 需要等待
			Thread.sleep(2000);
			List<Map> productIDsqllist2 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql2 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validStart"));
			String svalidEndbysql2= (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validEnd"));	
			//断言
			Logger.verifyNotEquals(svalidStartbysql2, svalidStartbysql1, "SQL对比商品开始销售时间发生变化");
			Logger.verifyNotEquals(svalidEndbysql2, svalidEndbysql1, "SQL对比商品结束销售时间发生变化");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_AutoRefreshProductsMessageHandler_002() {
		Logger.start(true,"正在执行中不会继续添加任务");
		try {
			Integer sellerId=3383;
			String sellerName="wesper";
			Logger.comment("先调用一次任务保证数据库中有记录");
			autorefreshproductsmessagehandlerBean.setUserId(sellerId);
			autorefreshproductsmessagehandlerCall.setData(autorefreshproductsmessagehandlerBean);
			autorefreshproductsmessagehandlerCall.callService();			
			Logger.debug(intergratedProductMapper.selectSellerLoginLimitAutoOnShevelByUserId(sellerId).get(0));
			String SellerLoginLimitAutoOnShevelId=intergratedProductMapper.selectSellerLoginLimitAutoOnShevelByUserId(sellerId).get(0).get("SellerLoginLimitAutoOnShevelId").toString();
			intergratedProductMapper.updateSellerLoginLimitAutoOnShevelAsSellerLoginLimitAutoOnShevelId(SellerLoginLimitAutoOnShevelId, "P");
//			Map<String, Object> updateMap = new HashMap<String, Object>();
//
//			updateMap.put("sellerName", sellerName);
//			updateMap.put("sellerId", sellerId);
//			//拼邮
//			updateMap.put("product->catalogStatus", 7);
//			//使用原时间 影响validStart validEnd
//			updateMap.put("product->onSaleType", -1);
//			//设置自动上架
//			updateMap.put("product->autoRefresh", true);
//			updateMap.put("product->productName",
//					"自动化测试_定时上架商品 "
//							+ YMTDateUtil.getBeforeOrNextDay(0));
//
//			//设为为过去10天前发布的商品
			String vstart=YMTDateUtil.getBeforeOrNextDay(-10, YMTDateUtil.YMDTHMS_STRING);
//			updateMap.put("product->validStart", vstart);
			String vend=YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
		//	updateMap.put("product->validEnd", vend);
//			JSONObject addNewProducthistoryObject = ProductManagerCallServiceV2.addNewProduct(updateMap);
			
			// update by wuwen addproductmock
            AddSellerProductRequest addProdReq = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
            addProdReq.setSellerId(sellerId);
            addProdReq.setSellerName(sellerName);
            addProdReq.getProduct().setCatalogStatus(5);
            addProdReq.getProduct().setOnSaleType(-1);
            addProdReq.getProduct().setAutoRefresh(true);
            addProdReq.getProduct().setProductName("自动化测试_定时上架商品"+ YMTDateUtil.getBeforeOrNextDay(0));
            addProdReq.getProduct().setValidStart(vstart);
            addProdReq.getProduct().setValidEnd(vend);
            String productID = ProductManagerCallServiceV3.AddSellerProduct(addProdReq);
            
			//Logger.verifyEquals(addNewProducthistoryObject.getInt("Code"), 200, "响应报文-返回码");
			//String productID =  addNewProducthistoryObject.getJSONObject("Data").getString("ProductId");
			YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
			List<Map> productIDsqllist1 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validStart"));
			String svalidEndbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validEnd"));	
			autorefreshproductsmessagehandlerBean.setUserId(sellerId);
			autorefreshproductsmessagehandlerCall.setData(autorefreshproductsmessagehandlerBean);
			autorefreshproductsmessagehandlerCall.callService();			
			Logger.verifyEquals("ok", autorefreshproductsmessagehandlerCall.getReturnData(), "验证返回");
			//发送总线 需要等待
			Thread.sleep(2000);
			List<Map> productIDsqllist2 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql2 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validStart"));
			String svalidEndbysql2= (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validEnd"));	
			//断言
			Logger.verifyEquals(svalidStartbysql2, svalidStartbysql1, "SQL对比商品开始销售时间发生变化");
			Logger.verifyEquals(svalidEndbysql2, svalidEndbysql1, "SQL对比商品结束销售时间发生变化");
			//结束后更新D
			intergratedProductMapper.updateSellerLoginLimitAutoOnShevelAsSellerLoginLimitAutoOnShevelId(SellerLoginLimitAutoOnShevelId, "D");
			
		} catch (Exception e) {
			
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_AutoRefreshProductsMessageHandler_003() {
		Logger.start(true,"3天外到期商品validEnd>now+3定时不会自动延期");
		try {
			Integer sellerId=3383;
			String sellerName="wesper";
			
//			//删除同步记录
			intergratedProductMapper.deleteSellerLoginInfoByUserId(sellerId);
//			Map<String, Object> updateMap = new HashMap<String, Object>();
//
//			updateMap.put("sellerName", sellerName);
//			updateMap.put("sellerId", sellerId);
//			//拼邮
//			updateMap.put("product->catalogStatus", 7);
//			//使用原时间 影响validStart validEnd
//			updateMap.put("product->onSaleType", -1);
//			//设置自动上架
//			updateMap.put("product->autoRefresh", true);
//			updateMap.put("product->productName",
//					"自动化测试_定时上架商品 "
//							+ YMTDateUtil.getBeforeOrNextDay(0));
//
//			//设为为过去10天前发布的商品
			String vstart=YMTDateUtil.getBeforeOrNextDay(-10, YMTDateUtil.YMDTHMS_STRING);
//			updateMap.put("product->validStart", vstart);
			String vend=YMTDateUtil.getBeforeOrNextDay(4, YMTDateUtil.YMDTHMS_STRING);
//			updateMap.put("product->validEnd", vend);
//			JSONObject addNewProducthistoryObject = ProductManagerCallServiceV2.addNewProduct(updateMap);
//			Logger.verifyEquals(addNewProducthistoryObject.getInt("Code"), 200, "响应报文-返回码");
//			String productID =  addNewProducthistoryObject.getJSONObject("Data").getString("ProductId");
			
			// update by wuwen addproductmock
            AddSellerProductRequest addProdReq = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
            addProdReq.setSellerId(sellerId);
            addProdReq.setSellerName(sellerName);
            addProdReq.getProduct().setCatalogStatus(5);
            addProdReq.getProduct().setOnSaleType(-1);
            addProdReq.getProduct().setAutoRefresh(true);
            addProdReq.getProduct().setProductName("自动化测试_定时上架商品"+ YMTDateUtil.getBeforeOrNextDay(0));
            addProdReq.getProduct().setValidStart(vstart);
            addProdReq.getProduct().setValidEnd(vend);
            String productID = ProductManagerCallServiceV3.AddSellerProduct(addProdReq);
            
			YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
			List<Map> productIDsqllist1 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validStart"));
			String svalidEndbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validEnd"));	
			autorefreshproductsmessagehandlerBean.setUserId(sellerId);
			autorefreshproductsmessagehandlerCall.setData(autorefreshproductsmessagehandlerBean);
			autorefreshproductsmessagehandlerCall.callService();			
			Logger.verifyEquals("ok", autorefreshproductsmessagehandlerCall.getReturnData(), "验证返回");
			//发送总线 需要等待
			Thread.sleep(2000);
			List<Map> productIDsqllist2 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql2 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validStart"));
			String svalidEndbysql2= (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validEnd"));	
			//断言
			Logger.verifyEquals(svalidStartbysql2, svalidStartbysql1, "SQL对比商品开始销售时间发生变化");
			Logger.verifyEquals(svalidEndbysql2, svalidEndbysql1, "SQL对比商品结束销售时间发生变化");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_AutoRefreshProductsMessageHandler_004() {
		Logger.start(true,"已经到期商品validEnd<now定时不会自动延期");
		try {
			Integer sellerId=3383;
			String sellerName="wesper";
			
//			//删除同步记录
			intergratedProductMapper.deleteSellerLoginInfoByUserId(sellerId);
//			Map<String, Object> updateMap = new HashMap<String, Object>();
//
//			updateMap.put("sellerName", sellerName);
//			updateMap.put("sellerId", sellerId);
//			//拼邮
//			updateMap.put("product->catalogStatus", 7);
//			//使用原时间 影响validStart validEnd
//			updateMap.put("product->onSaleType", -1);
//			//设置自动上架
//			updateMap.put("product->autoRefresh", true);
//			updateMap.put("product->productName",
//					"自动化测试_定时上架商品 "
//							+ YMTDateUtil.getBeforeOrNextDay(0));
//
//			//设为为过去10天前发布的商品
			String vstart=YMTDateUtil.getBeforeOrNextDay(-10, YMTDateUtil.YMDTHMS_STRING);
//			updateMap.put("product->validStart", vstart);
			String vend=YMTDateUtil.getBeforeOrNextDay(-1, YMTDateUtil.YMDTHMS_STRING);
//			updateMap.put("product->validEnd", vend);
//			JSONObject addNewProducthistoryObject = ProductManagerCallServiceV2.addNewProduct(updateMap);
//			Logger.verifyEquals(addNewProducthistoryObject.getInt("Code"), 200, "响应报文-返回码");
//			String productID =  addNewProducthistoryObject.getJSONObject("Data").getString("ProductId");
			
			// update by wuwen addproductmock
            AddSellerProductRequest addProdReq = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
            addProdReq.setSellerId(sellerId);
            addProdReq.setSellerName(sellerName);
            addProdReq.getProduct().setCatalogStatus(5);
            addProdReq.getProduct().setOnSaleType(-1);
            addProdReq.getProduct().setAutoRefresh(true);
            addProdReq.getProduct().setProductName("自动化测试_定时上架商品"+ YMTDateUtil.getBeforeOrNextDay(0));
            addProdReq.getProduct().setValidStart(vstart);
            addProdReq.getProduct().setValidEnd(vend);
            String productID = ProductManagerCallServiceV3.AddSellerProduct(addProdReq);
            
			YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
			List<Map> productIDsqllist1 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validStart"));
			String svalidEndbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validEnd"));	
			autorefreshproductsmessagehandlerBean.setUserId(sellerId);
			autorefreshproductsmessagehandlerCall.setData(autorefreshproductsmessagehandlerBean);
			autorefreshproductsmessagehandlerCall.callService();			
			Logger.verifyEquals("ok", autorefreshproductsmessagehandlerCall.getReturnData(), "验证返回");
			//发送总线 需要等待
			Thread.sleep(2000);
			List<Map> productIDsqllist2 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql2 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validStart"));
			String svalidEndbysql2= (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validEnd"));	
			//断言
			Logger.verifyEquals(svalidStartbysql2, svalidStartbysql1, "SQL对比商品开始销售时间发生变化");
			Logger.verifyEquals(svalidEndbysql2, svalidEndbysql1, "SQL对比商品结束销售时间发生变化");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_AutoRefreshProductsMessageHandler_005() {
		Logger.start(true,"CheckStatus=-1巡检强制下架商品不会自动延期");
		try {
			Integer sellerId=3383;
			String sellerName="wesper";
			
//			//删除同步记录
			intergratedProductMapper.deleteSellerLoginInfoByUserId(sellerId);
//			Map<String, Object> updateMap = new HashMap<String, Object>();
//
//			updateMap.put("sellerName", sellerName);
//			updateMap.put("sellerId", sellerId);
//			//拼邮
//			updateMap.put("product->catalogStatus", 7);
//			//使用原时间 影响validStart validEnd
//			updateMap.put("product->onSaleType", 1);
//			//设置自动上架
//			updateMap.put("product->autoRefresh", true);
//			updateMap.put("product->productName",
//					"自动化测试_定时上架商品 "
//							+ YMTDateUtil.getBeforeOrNextDay(0));
//
//			//设为为过去10天前发布的商品
			String vstart=YMTDateUtil.getBeforeOrNextDay(-10, YMTDateUtil.YMDTHMS_STRING);
//			updateMap.put("product->validStart", vstart);
			String vend=YMTDateUtil.getBeforeOrNextDay(-1, YMTDateUtil.YMDTHMS_STRING);
//			updateMap.put("product->validEnd", vend);
//			JSONObject addNewProducthistoryObject = ProductManagerCallServiceV2.addNewProduct(updateMap);
//			Logger.verifyEquals(addNewProducthistoryObject.getInt("Code"), 200, "响应报文-返回码");
//			String productID =  addNewProducthistoryObject.getJSONObject("Data").getString("ProductId");
			
			// update by wuwen addproductmock
            AddSellerProductRequest addProdReq = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
            addProdReq.setSellerId(sellerId);
            addProdReq.setSellerName(sellerName);
            addProdReq.getProduct().setCatalogStatus(5);
            addProdReq.getProduct().setOnSaleType(1);
            addProdReq.getProduct().setAutoRefresh(true);
            addProdReq.getProduct().setProductName("自动化测试_定时上架商品"+ YMTDateUtil.getBeforeOrNextDay(0));
            addProdReq.getProduct().setValidStart(vstart);
            addProdReq.getProduct().setValidEnd(vend);
            String productID = ProductManagerCallServiceV3.AddSellerProduct(addProdReq);
            
			YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
			Logger.comment("修改数据库CheckStatus=-1");
			ymtProductsIWapper.updateCheckStatus(productID, -1);
			List<Map> productIDsqllist1 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validStart"));
			String svalidEndbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validEnd"));	
			autorefreshproductsmessagehandlerBean.setUserId(sellerId);
			autorefreshproductsmessagehandlerCall.setData(autorefreshproductsmessagehandlerBean);
			autorefreshproductsmessagehandlerCall.callService();			
			Logger.verifyEquals("ok", autorefreshproductsmessagehandlerCall.getReturnData(), "验证返回");
			//发送总线 需要等待
			Thread.sleep(2000);
			List<Map> productIDsqllist2 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql2 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validStart"));
			String svalidEndbysql2= (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validEnd"));	
			//断言
			Logger.verifyEquals(svalidStartbysql2, svalidStartbysql1, "SQL对比商品开始销售时间发生变化");
			Logger.verifyEquals(svalidEndbysql2, svalidEndbysql1, "SQL对比商品结束销售时间发生变化");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_AutoRefreshProductsMessageHandler_006() {
		Logger.start(true,"iaction=-1删除商品不会自动延期");
		try {
			Integer sellerId=3383;
			String sellerName="wesper";
			
//			//删除同步记录
			intergratedProductMapper.deleteSellerLoginInfoByUserId(sellerId);
//			Map<String, Object> updateMap = new HashMap<String, Object>();
//
//			updateMap.put("sellerName", sellerName);
//			updateMap.put("sellerId", sellerId);
//			//拼邮
//			updateMap.put("product->catalogStatus", 7);
//			//使用原时间 影响validStart validEnd
//			updateMap.put("product->onSaleType", 1);
//			//设置自动上架
//			updateMap.put("product->autoRefresh", true);
//			updateMap.put("product->productName",
//					"自动化测试_定时上架商品 "
//							+ YMTDateUtil.getBeforeOrNextDay(0));
//
//			//设为为过去10天前发布的商品
			String vstart=YMTDateUtil.getBeforeOrNextDay(-10, YMTDateUtil.YMDTHMS_STRING);
//			updateMap.put("product->validStart", vstart);
			String vend=YMTDateUtil.getBeforeOrNextDay(-1, YMTDateUtil.YMDTHMS_STRING);
//			updateMap.put("product->validEnd", vend);
//			JSONObject addNewProducthistoryObject = ProductManagerCallServiceV2.addNewProduct(updateMap);
//			Logger.verifyEquals(addNewProducthistoryObject.getInt("Code"), 200, "响应报文-返回码");
//			String productID =  addNewProducthistoryObject.getJSONObject("Data").getString("ProductId");
			
			// update by wuwen addproductmock
            AddSellerProductRequest addProdReq = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
            addProdReq.setSellerId(sellerId);
            addProdReq.setSellerName(sellerName);
            addProdReq.getProduct().setCatalogStatus(5);
            addProdReq.getProduct().setOnSaleType(1);
            addProdReq.getProduct().setAutoRefresh(true);
            addProdReq.getProduct().setProductName("自动化测试_定时上架商品"+ YMTDateUtil.getBeforeOrNextDay(0));
            addProdReq.getProduct().setValidStart(vstart);
            addProdReq.getProduct().setValidEnd(vend);
            String productID = ProductManagerCallServiceV3.AddSellerProduct(addProdReq);
            
            
			YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
			Logger.comment("删除商品");
			ArrayList productIds=new ArrayList<>();
			productIds.add(productID);
			ProductManagerCallServiceV2.batchDeleteProducts(productIds, sellerId);
			List<Map> productIDsqllist1 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validStart"));
			String svalidEndbysql1 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist1.get(0).get("validEnd"));	
			autorefreshproductsmessagehandlerBean.setUserId(sellerId);
			autorefreshproductsmessagehandlerCall.setData(autorefreshproductsmessagehandlerBean);
			autorefreshproductsmessagehandlerCall.callService();			
			Logger.verifyEquals("ok", autorefreshproductsmessagehandlerCall.getReturnData(), "验证返回");
			//发送总线 需要等待
			Thread.sleep(2000);
			List<Map> productIDsqllist2 = ymtProductsIWapper.selectProductByProductIdforMap(productID);
			String svalidStartbysql2 = (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validStart"));
			String svalidEndbysql2= (new SimpleDateFormat("yyyy-MM-dd HH")).format(productIDsqllist2.get(0).get("validEnd"));	
			//断言
			Logger.verifyEquals(svalidStartbysql2, svalidStartbysql1, "SQL对比商品开始销售时间发生变化");
			Logger.verifyEquals(svalidEndbysql2, svalidEndbysql1, "SQL对比商品结束销售时间发生变化");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}